const app = getApp()

Page({
  data: {

  },
  // 事件处理函数
  bindViewTap() {
    wx.showToast({
      title: '你好啊,世界',
    })
  },
  onLoad() {

    this.setData({
      name: app.globalData.name,
      username: app.globalData.username,
      sex: app.globalData.sex,
      age: app.globalData.age,
      arae: app.globalData.area
    })
  },

  // -----------弹窗模块以及视图层-----------

  //显示模块对话框
  infoup: function () {
    this.setData({
      showModal: true
    })
  },
  //隐藏模块对话框
  hideModal: function () {
    this.setData({
      showModal: false
    });
  },
  // 对话框取消按钮点击事件
  onCancelname: function () {
    this.hideModal();
  },
  // 输入框内容改变事件
  inputChangename: function (e) {

    this.setData({
      inputData: e.detail.value
    })


  },
  //  对话框确认按钮点击事件
  onConfirmname: function (e) {

    console.log(e.detail.value)
    // this.setData({
    //   showModal: false,
    //   updata:that.data.stuName
    // });
    wx.hideKeyboard({
      complete: res => {
        console.log('hideKeyboard res', res)
      }
    })
  },

  onConfirmname: function () {
    var data = this.data.inputData.split('\n');
    var sex = data[0]
    var age = data[1]
    var area = data[2]
    console.log(sex, age, area)
    app.globalData.sex = sex
    app.globalData.age = age
    app.globalData.area = area
    this.setData({
      showModal: !this.data.showModal,
      sex: app.globalData.sex,
      age: app.globalData.age,
      arae: app.globalData.area
    });

    wx.hideKeyboard({
      complete: res => {
        console.log('hideKeyboard res', res)
      }
    })
  },
  // 截图分享
  onShareAppMessage() {
    const promise = new Promise(resolve => {
      setTimeout(() => {
        resolve({
          title: '生科课表'
        })
      }, 1000)
    })
    return {
      title: '生科课表',
      path: './index',
      promise
    }
  }
})